package org.jeecg.modules.trainingRecords.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.jeecg.modules.trainingRecords.entity.TrainingRecords;
import org.jeecg.modules.trainingRecords.mapper.TrainingRecordsMapper;
import org.jeecg.modules.trainingRecords.service.ITrainingRecordsService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * @Description: 培训记录
 * @Author: jeecg-boot
 * @Date:   2024-09-27
 * @Version: V1.0
 */
@Service
public class TrainingRecordsServiceImpl extends ServiceImpl<TrainingRecordsMapper, TrainingRecords> implements ITrainingRecordsService {

    @Override
    public TrainingRecords getLastByOpenId(String openId) {
        LambdaQueryWrapper<TrainingRecords> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(TrainingRecords::getOpenId, openId);
        wrapper.orderByDesc(TrainingRecords::getCreateTime);
        wrapper.last("limit 1");
        return baseMapper.selectOne(wrapper);
    }
}
